//
// Created by aaa on 2025/7/14.
//

#include<bits/stdc++.h>

using namespace std;

const int N = 1e3 + 10;
const int mod = 1e9 + 7;

int n,m,w,v;
int dp[N],c[N];

//求方案数
//4 5
//1 2
//2 4
//3 4
//4 6
int main(){
    cin >> n >> m;

    //不超过背包容量初始化
//    for(int i = 0;i <= m;i++) c[i] = 1;
    //恰好装满背包容量的初始化
    for(int i = 1;i <= m;i++) dp[i] = INT_MIN;
    c[0] = 1,dp[0] = 0;

    for(int i = 1;i <= n;i++){
        cin >> w >> v;
        for(int j = m;j >= w;j--){
            if(dp[j - w] + v > dp[j]){
                dp[j] = dp[j - w] + v;
                c[j] = c[j - w];
            }else if(dp[j - w] + v == dp[j]){
                c[j] = (c[j] + c[j - w]) % mod;
            }
        }
    }

    cout << c[m];


    return 0;
}